/*
* Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  Implementation of the ECom interface for NFC External
*               Content Handler interface.
*/

#ifndef __CONTENTHANDLER_H__
#define __CONTENTHANDLER_H__

#include <nfcch.h>

/**
 * NFC External Content Handler class for the NDEF record type
 * "urn:nfc:ext:www.forum.nokia.com:nfcchpt".
 *
 * The types of NFC records this plugin handles are defined in the plugin
 * registration resource file "contenthandler.rss". The mapping of NFC record
 * types to class instances that actually process the content is done via the
 * implementation proxy table defined in the file "implementationproxy.cpp".
 *
 * This class provides an empty implementation for a potentially leaving record
 * processor.
 */
class CContentHandler : public CNfcCH
    {
public:

    /**
     * Symbian two-phased constructor.
     *
     * Instantiates an object of type CContentHandler.
     *
     * @return Pointer to the newly creates instance, ownership of the object
     *   is transferred to the caller.
     */
    static CContentHandler* NewL();

    /**
     * C++ destructor.
     */
    virtual ~CContentHandler();

public:

    /**
     * From base class CNfcCH. Called by the initiator when processing of
     * an NDEF message containing one or more records of the types registered
     * by this plugin is required.
     *
     * @param aRequestStatus The initiator's status to be completed when
     *   processing is done.
     * @param aMessage The NDEF message to process, ownership of the object
     *   is transferred to this class.
     */
    virtual void HandleNdefMessage(
        TRequestStatus& aRequestStatus,
        CNdefMessage* aMessage );

    /**
     * From base class CNfcCH. Called by the initiator to indicate that any
     * ongoing NDEF message processing should be cancelled.
     */
    virtual void HandleNdefMessageCancel();

private:
    
    /**
     * C++ constructor.
     */
    CContentHandler();

    /**
     * Symbian second phase constructor.
     */
    void ConstructL();

    /**
     * Called from HandleNdefMessage() to allow for leaving functions to be
     * called while NDEF message processing.
     *
     * If this function causes a leave, the initiator's request status is
     * completed with the corresponding error code.
     *
     * @param aMessage The NDEF message to process, ownership of the object
     *   is transferred to this class. If there is no need to keep the message
     *   after it has been processed by this function, it should be deleted
     *   before returning.
     */
    void HandleNdefMessageL( CNdefMessage* aMessage );
    };

#endif // __CONTENTHANDLER_H__
